//
//  MovieViewController.m
//  XMLY
//
//  Created by 曾杰 on 15/11/7.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "MovieViewController.h"
#import "SoundBookCell.h"
#import "PKRequestManager.h"
#import "SoundBookModel.h"
#import "UIImageView+WebCache.h"
#import "BookListTableViewController.h"
#import "HACursor.h"
#import "MovieRecommendTableViewController.h"
@interface MovieViewController ()
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong) BookListTableViewController *bookListVC;
@property (nonatomic, strong) UITableView *textView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) NSString *urlStr;
@property (nonatomic, strong) NSMutableArray *pageViews;
@property (nonatomic, strong) MovieRecommendTableViewController *recommendVC;
@end

@implementation MovieViewController

- (NSArray *)items {
    if (_items == nil) {
        _items = @[@"推荐", @"影评地带", @"原声记忆", @"大话影人", @"电影抢先听", @"电影资讯"];
    }
    return _items;
}

-(NSMutableArray *)dataArr
{
    if (_dataArr == nil) {
        self.dataArr = [NSMutableArray arrayWithCapacity:0];
    }
    return _dataArr;
}

-(NSMutableArray *)pageViews
{
    if (_pageViews == nil) {
        self.pageViews = [ NSMutableArray array];
    }
    return _pageViews;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLabel.text = @"电影";
    HACursor *cursor = [[HACursor alloc]init];
    cursor.frame = CGRectMake(0, 64, SCREEN_WIDTH, 45);
    cursor.titles = self.items;
    cursor.pageViews = [self createPageViews];
    //设置根滚动视图的高度
    cursor.rootScrollViewHeight = self.view.frame.size.height -109;
    //默认值是白色
    cursor.titleNormalColor = [UIColor blackColor];
    //默认值是白色
    cursor.titleSelectedColor = [UIColor redColor];
    //是否显示排序按钮
    cursor.showSortbutton = NO;
    //默认的最小值是5，小于默认值的话按默认值设置
    cursor.minFontSize = 15;
    //默认的最大值是25，小于默认值的话按默认值设置，大于默认值按设置的值处理
    cursor.maxFontSize = 25;
    //cursor.isGraduallyChangFont = NO;
    //在isGraduallyChangFont为NO的时候，isGraduallyChangColor不会有效果
    //cursor.isGraduallyChangColor = NO;
    [self.view addSubview:cursor];
    
}


- (NSMutableArray *)createPageViews{
    for (NSInteger i = 0; i < self.items.count; i++) {
        if (i == 0) {
            _recommendVC = [[MovieRecommendTableViewController alloc]init];            _recommendVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v2/category/recommends?categoryId=23&contentType=album&device=iPhone&scale=2&version=4.3.20";
            [self.pageViews addObject:_recommendVC.view];
        }
        else
        {
            [self dataWithIndex:i];
        }
    }
    return self.pageViews;
}



- (void)dataWithIndex:(long)index
{
    switch (index) {
        case 1:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=23&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%BD%B1%E8%AF%84%E5%9C%B0%E5%B8%A6";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 2:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=23&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%8E%9F%E5%A3%B0%E8%AE%B0%E5%BF%86";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 3:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=23&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E5%A4%A7%E8%AF%9D%E5%BD%B1%E4%BA%BA";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 4:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=23&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%94%B5%E5%BD%B1%E6%8A%A2%E5%85%88%E5%90%AC";
            [self.pageViews addObject:_bookListVC.view];
            break;
        case 5:
            _bookListVC = [[BookListTableViewController alloc]init];
            _bookListVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=23&device=iPhone&pageId=1&pageSize=20&status=0&tagName=%E7%94%B5%E5%BD%B1%E8%B5%84%E8%AE%AF";
            [self.pageViews addObject:_bookListVC.view];
            break;
        default:
            break;
            
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
